<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="box">
        <input type="text" v-model="mytext">
        <ul>
            <li v-for="data in filterList()" :key="data">
                {{data}}
            </li>
        </ul>
        <!-- 也可以这样写：模板方法 -->
        <input type="text" v-model="mytext1">
        <ul>
            <template v-for="item in datalist1" :key="item">
              <li v-if="item.includes(mytext1)">{{item}}</li>
                
            </template>
        </ul>
    </div>

    <script>
        var obj = {
            data() {
                return {
                    mytext: '',
                    mytext1: '',
                    datalist: ['aaa', 'abb', 'aab', 'bcc', 'abc', 'bcd', 'add', 'acd'],
                    datalist1: ['aaa', 'abb', 'aab', 'bcc', 'abc', 'bcd', 'add', 'acd']
                }
            },
            methods: {
                filterList(evt) {
                    return this.datalist.filter(item => item.includes(this.mytext))
                }
            }
        }
        Vue.createApp(obj).mount('#box')
    </script>
</body>

</html>